<?php
header("Content-Type: text/html; charset=utf-8");  		
$num = 20; //返回数量
$url = 'http://api.tianapi.com/wxnew/?key=您的APIKEY&num='.$num.'&rand';     //API接口
$ch = curl_init();  
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
//  var_dump(json_decode($file_contents ));
      $json = json_decode($file_contents,true);
      if($json['code'] == 200){
         $txapi=$json['newslist'];
         for ($i = 0; $i < $num; $i++){
              //   echo var_dump($de_json);
                   $title = $txapi[$i]['title']; //文章标题
		           $desc =  $txapi[$i]['description']; //文章描述
                   $pic =   $txapi[$i]['picUrl'];  //封面图片
                   $url =   $txapi[$i]['url'];  //文章链接
		   echo $title."<br/>".$desc."<br/>".$pic."<br/>".$url."<br/>";
                } 
          }else{	
		echo "返回错误，状态消息：".$json['msg'];
	  }